Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(OpenApiType): Prevent arrays indexed by non-strings #142

Merged

Conversation

provokateurin
Copy link
Member

JSON objects can only be indexed by string, so any other type has to be prevented.
In theory we could parse array<int, ...> as simple JSON array, but that is very likely not the intended use since there is no way to skip int keys in JSON and thus array<...> or list<...> should be used.
For reference: nextcloud/tables#1169

@nickvergessen
Copy link
Member

In theory we could parse array<int, ...> as simple JSON array,

No you can not.

[0 => 'zero', 2 => 'two'] is array<int, ...> but not a valid JSON array

@provokateurin
Copy link
Member Author

Right I checked, it results in {"0":"zero","2":"two"} which just shows that it should be entirely forbidden.

@provokateurin
Copy link
Member Author

Anything against merging this?

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff in talk looks empty, so should be good

@nickvergessen nickvergessen merged commit e6a1936 into main Jul 23, 2024
12 checks passed
@provokateurin provokateurin deleted the fix/openapitype/prevent-non-string-indexed-arrays branch July 23, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants